/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package myprogramui.comp;

import javafx.animation.RotateTransition;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
import javafx.util.Duration;

/**
 *
 * @author Administrator
 */
public class Circle_Ani extends Group{
    private Stage primaryStage;
    public Circle_Ani(Stage primaryStage){
        this.primaryStage=primaryStage;
        ImageView cir0=new ImageView("Image_no_pair/cirani/cir1.png");
        ImageView cir1=new ImageView("Image_no_pair/cirani/cir2.png");
        ImageView cir2=new ImageView("Image_no_pair/cirani/cir3.png");
//        cir1.setTranslateX((564-365)/2);
//        cir1.setTranslateY((564-365)/2);
//        cir2.setTranslateX((564-190)/2);
//        cir2.setTranslateY((564-190)/2);
        cir0.setTranslateX(-564/2);
        cir0.setTranslateY(-564/2);
        cir1.setTranslateX(-365/2);
        cir1.setTranslateY(-365/2);
        cir2.setTranslateX(-190/2);
        cir2.setTranslateY(-190/2);
        this.getChildren().add(cir0); 
        this.getChildren().add(cir1); 
        this.getChildren().add(cir2); 
        
        final RotateTransition rt = new RotateTransition(Duration.millis(3000), cir0);
        rt.setByAngle(720);
        rt.setCycleCount(1);
        rt.setAutoReverse(true);
        
        final RotateTransition rt1 = new RotateTransition(Duration.millis(3000), cir1);
        rt1.setByAngle(-720);
        rt1.setCycleCount(1);
        rt1.setAutoReverse(true);
        
        final RotateTransition rt2 = new RotateTransition(Duration.millis(3000), cir2);
        rt2.setByAngle(720);
        rt2.setCycleCount(1);
        rt2.setAutoReverse(true);
        
        this.setOnMouseEntered(new EventHandler<MouseEvent>() {

            @Override
            public void handle(MouseEvent event) {
                rt.play();
                rt1.play();
                rt2.play();
                
            }
        });
    }
}
